package com.nursing.controller.duty;

import com.nursing.bean.DutySchedule;
import com.nursing.model.Result;
import com.nursing.model.dto.DutyDto;
import com.nursing.service.DutyService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dutySchedule")
public class DutyScheduleController {
    private final DutyService dutyService;
    public DutyScheduleController(DutyService dutyService) {
        this.dutyService = dutyService;
    }

    @GetMapping("/getDutyList")
    public Result<List<DutyDto>> getDutyList(@RequestParam(value = "nurseId", required = false) Integer nurseId) {
        List<DutyDto> dutyList = dutyService.getDutyList(nurseId);
        return Result.success(dutyList);
    }

    @GetMapping("/editStatus")
    public Result<String> editStatus(Integer id,Integer status) {
         dutyService.editStatus(id,status);
        return Result.success("success");
    }

    @PostMapping("/add")
    public Result<String>  addDutySchedule(@RequestBody DutySchedule dutySchedule) {
        dutyService.addDutySchedule(dutySchedule);
        return Result.success("添加成功");
    }

    @DeleteMapping("/delete")
    public Result<String> deleteDutySchedule(@RequestParam int id) {
        dutyService.deleteDutySchedule(id);
        return Result.success("删除成功");
    }
}
